<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>注册</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <div class="container mt-5">
        <div class="row justify-content-center">
            <div class="col-md-6">
                <div class="card">
                    <div class="card-header">
                        <h3 class="text-center">用户注册</h3>
                    </div>
                    <div class="card-body">
                        <!-- 错误消息显示 -->
                        <div th:if="${error}" class="alert alert-danger" role="alert">
                            <span th:text="${error}"></span>
                        </div>
                        <!-- 成功消息显示 -->
                        <div th:if="${param.success}" class="alert alert-success" role="alert">
                            注册成功！
                        </div>
                        <form th:action="@{/register}" method="post">
                            <div class="form-group">
                                <label for="username">用户名</label>
                                <input type="text" class="form-control" id="username" name="username" th:value="${user?.username}" required>
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input type="password" class="form-control" id="password" name="password" th:value="${user?.password}" required>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn btn-primary btn-block">注册</button>
                            </div>
                            <div class="text-center">
                                <a th:href="@{/login}">已有账号？立即登录</a>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>